//
//  GetDataFromDouBan.m
//  PageViewControlerDemo
//
//  Created by lgq on 2017/3/13.
//  Copyright © 2017年 liukun. All rights reserved.
//

#import "GetDataFromDouBan.h"

@implementation GetDataFromDouBan


- (void)getData:(NSString *)dataUrl type:(NSString *)type keyword:(NSString *)keyword completed:(completedHandle)Handle
{
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    AFHTTPSessionManager *requestManager = [AFHTTPSessionManager manager];
    requestManager.requestSerializer = [AFJSONRequestSerializer serializer];
    requestManager.responseSerializer = [AFJSONResponseSerializer serializer];
    NSSet *contenttypes = [NSSet setWithObjects:@"text/html", nil];
    requestManager.responseSerializer.acceptableContentTypes = contenttypes;
    
    [manager GET:dataUrl parameters:@{@"q":keyword,@"count":@"10"} progress:^(NSProgress * _Nonnull downloadProgress) {
        ;
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSLog(@"responseObject:[%@]",responseObject);
        Handle(responseObject);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        ;
    }];
}

@end
